Skip to content

Conversation

@nhaehnle
Copy link
Member

@nhaehnle nhaehnle commented Oct 7, 2024

GCC 13 produced a warning that:

.../llvm-dialects/lib/TableGen/Evaluator.cpp:653:31: warning: possibly dangling reference to a temporary [-Wdangling-reference]
653 | const ConstraintSystem &childSystem = logicOr->branches()[i];
| ^~~~~~~~~~~
.../llvm-dialects/lib/TableGen/Evaluator.cpp:653:66: note: the temporary was destroyed at the end of the full expression ‘logicOr->llvm_dialects::LogicOr::branches().llvm::ArrayRef<llvm_dialects::ConstraintSystem>::operator
653 | const ConstraintSystem &childSystem = logicOr->branches()[i];
| ^

This warning seems wrong. The temporary ArrayRef returned by LogicOr::branches() is destroyed, yes, but the reference returned by operator[] isn't a reference into the ArrayRef itself, so it shouldn't matter.

Oh well. Using a for-each loop is nicer anyway.

GCC 13 produced a warning that:

.../llvm-dialects/lib/TableGen/Evaluator.cpp:653:31: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  653 |       const ConstraintSystem &childSystem = logicOr->branches()[i];
      |                               ^~~~~~~~~~~
.../llvm-dialects/lib/TableGen/Evaluator.cpp:653:66: note: the temporary was destroyed at the end of the full expression ‘logicOr->llvm_dialects::LogicOr::branches().llvm::ArrayRef<llvm_dialects::ConstraintSystem>::operator[](((size_t)i))’
  653 |       const ConstraintSystem &childSystem = logicOr->branches()[i];
      |                                                                  ^

This warning seems wrong. The temporary ArrayRef returned by LogicOr::branches()
is destroyed, yes, but the reference returned by operator[] isn't a
reference into the ArrayRef itself, so it shouldn't matter.

Oh well. Using a for-each loop is nicer anyway.
Copy link
Contributor

@tsymalla-AMD tsymalla-AMD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me

@nhaehnle nhaehnle merged commit a0b2948 into GPUOpen-Drivers:dev Oct 8, 2024
8 checks passed
@nhaehnle nhaehnle deleted the pub-fix-warning branch October 8, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants